Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests and bug fixes for XmlRpcServer #1243

Merged

Conversation

trainman419
Copy link
Contributor

Add integration tests for the XmlRpcServer interacting with an XmlRpcClient in the same process, particularly around the behavior when the server process runs out of available file handles.

Update the XmlRpcServer with two different mitigations for file handle exhaustion (Fixes #914, replaces #960 and #977):

  • Measure the number of free file handles and reject incoming connections if the pool of free file descriptors is too small. This actively rejects incoming clients instead of waiting for complete file
    handle exhaustion, which would leave clients in a pending state until a file descriptor becomes free.
  • If accept fails due to complete file handle exhaustion, temporarily stop calling accept on this socket. This prevents a busy-loop where poll() believes the listening socket is readable, but accept() fails to
    allocate a file descriptor and leaves the socket in a readable state.

@@ -3,6 +3,23 @@ if(TARGET xmlrpcvalue_base64)
target_link_libraries(xmlrpcvalue_base64 xmlrpcpp)
endif()

# Some of the tests that follow use boost threads.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add <test_depend>boost</test_depend>, since inclusion of this file is guarded by CATKIN_ENABLE_TESTING.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

ASSERT_TRUE(c.executeNonBlock("Hello", noArgs));

bool done = false;
for (int i = 0; i < 30; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a new file, ROS brace style, please (here and elsewhere). If you like, run astyle on it:

http://wiki.ros.org/roslint#Tips

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -32,14 +56,14 @@ XmlRpcServer::~XmlRpcServer()


// Add a command to the RPC server
void
void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert these whitespace changes (a follow-on commit which re-adds them is acceptable, as it will get squashed down anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted.

methods[2] = "Sum";
methods[3] = "system.listMethods";
methods[4] = "system.methodHelp";
methods[5] = "system.multicall";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm partial to boost::assign::list_of in these instances, but what's here is fine.

@mikepurvis
Copy link
Member

Looks great. Will wait for @dirk-thomas to weigh in, but this is a terrific set of validations, thank you!

Add integration tests for the XmlRpcServer interacting with an
XmlRpcClient in the same process, particularly around the behavior when
the server process runs out of available file handles.

Update the XmlRpcServer with two different mitigations for file handle
exhaustion (Fixes ros#914, replaces ros#960 and ros#977):
 * Measure the number of free file handles and reject incoming
connections if the pool of free file descriptors is too small. This
actively rejects incoming clients instead of waiting for complete file
handle exhaustion, which would leave clients in a pending state until a
file descriptor becomes free.
 * If accept fails due to complete file handle exhaustion, temporarily
stop calling accept on this socket. This prevents a busy-loop where
poll() believes the listening socket is readable, but accept() fails to
allocate a file descriptor and leaves the socket in a readable state.
@trainman419 trainman419 force-pushed the trainman419/fix_xmlrpcpp_bugs_6 branch from 69f3d29 to e0cf7a0 Compare December 14, 2017 04:24
@dirk-thomas
Copy link
Member

The patch itself looks fine to me. It does break ABI though so I am (as always) hesitant to merge this into an already released distro. I guess the argument will be "it doesn't matter for Lunar to break ABI and we want the patch now instead of for Melodic"?

@trainman419
Copy link
Contributor Author

I don't really have a stake in which version this merges into.

I will say that it fixes a fairly substantial bug for our use case, so I think it there is a strong argument for including it in Lunar. Since this isn't an API that is used by most clients, and it will be released in sync with roscpp, I think the impact of the ABI breakage will be low.

@dirk-thomas
Copy link
Member

Thank you for the patch.

@NikolausDemmel
Copy link
Contributor

Looks like this might have broken roscore on macos: #1357

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants